﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;

namespace AimGameLibrary.GameObject
{
    public class BaseGameObject: IDraw , IUpdateMainTime
    {
        public ViewData MyViewData;
        public NodeData MyData;
        //public NodeData MyNodeData;
        public NodeInputMode InputMode;
        public List<BaseGameObject> Listparent;
        public List<String> Listnameparent;
        

        public BaseGameObject ()
	    {
            Listparent = new List<BaseGameObject>();
            Listnameparent = new List<string>();
	    }

        public virtual void SetupParent(Dictionary<String, BaseGameObject> dictionary)
        {
            if (Listnameparent.Count > 0)
            {
                foreach (String keys in Listnameparent)
                {
                    if (dictionary.ContainsKey(keys) && keys != "NULL")
                        Listparent.Add(dictionary[keys]);
                    //else Listparent.Add(new BaseGameObject());
                }
            }
        }

        public virtual void SetupParent(Dictionary<string, BaseGameObject> dictionary, List<String> ListNameTarget, List<BaseGameObject> ListObjectTarget)
        {
            if (ListNameTarget.Count > 0)
                foreach (String keys in ListNameTarget)
                    if (dictionary.ContainsKey(keys) && keys != "NULL")
                        ListObjectTarget.Add(dictionary[keys]);
        }

        public virtual void LoadData(Identification getdata, int IndexData,NodeData node)
        { 
        
        }

        protected int GetIndex(int MainIndex)
        {
            int countSkip = 0;
            for (int i = 0; i < MainIndex; i++)
            {
                if (Listnameparent[i] == "NULL")
                    countSkip++;
                if (MainIndex - i == 1 && Listnameparent[i] == "NULL")
                    return 0;
            }
            return MainIndex - countSkip;
        }

        public virtual void Draw()
        { 
        
        }

        public virtual void UpdateTime(TimeSpan timespan)
        { }

        public virtual void UpdateGameTime(GameTime gametime)
        {

        }

        public virtual void UnLoadContent()
        { }
    }
}
